home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / QuickDraw / Restore Screen Cluts / PictDocument.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-08  |  10.8 KB  |  329 lines  |  [TEXT/MPS ]

  1. #ifndef __PICTDOCUMENT__
  2. #define __PICTDOCUMENT__
  3. /******************************************************************************\
  4. *
  5. * Apple Macintosh Developer Technical Support
  6. *
  7. * Header file for the Picture Document routines
  8. *
  9. * Program: ColorReset
  10. * File:    PictDocument.h
  11. *
  12. * by:      Forrest Tanaka
  13. *
  14. * Copyright © 1988-1992 Apple Computer, Inc.
  15. * All rights reserved.
  16. *
  17. \******************************************************************************/
  18.  
  19. #ifndef THINK_C
  20. #ifndef __WINDOWS__
  21. #include <Windows.h>
  22. #endif
  23.  
  24. #ifndef __FILES__
  25. #include <Files.h>
  26. #endif
  27. #endif
  28.  
  29. /******************************************************************************\
  30. * NAME & SYNOPSIS:
  31. * FindPictDoc: Find the Picture Document window for a specific file
  32. *
  33. * PARAMETERS:
  34. * FSSpecPtr fileSpec: Specification of file to search for
  35. *
  36. * DEFINITION:
  37. * FindPictDoc finds the Picture Document window associated with the file
  38. * specified by fileSpec.  A pointer to this window is returned.  If no matching
  39. * Picture Document window could be found, then nil is returned.
  40. *
  41. * RETURN VALUES:
  42. * Result: Pointer to the Picture Document window that’s associated with the file
  43. *         that’s specified by the fileSpec parameter.
  44. \******************************************************************************/
  45.  
  46. WindowPtr FindPictDoc(
  47.     FSSpecPtr fileSpec);
  48.  
  49.  
  50. /******************************************************************************\
  51. * NAME & SYNOPSIS:
  52. * NextPictDocWindow: Return a pointer to the next Picture Document window
  53. *
  54. * PARAMETERS:
  55. * WindowPtr aWindow: Window to start search from, or nil if want front-most
  56. *
  57. * DEFINITION:
  58. * This routine returns a pointer to the first Picture Document window in the
  59. * window list AFTER the window specified by aWindow.  If aWindow is nil, then
  60. * NextPictDocWindow returns a pointer to the first Picture Document window in
  61. * the window list (ie the front-most Picture Document window.  If no Picture 
  62. * Document windows could be found, then nil is returned.
  63. *
  64. * RETURN VALUES:
  65. * Result: Pointer to the Picture Document window that’s after the window that’s
  66. *         specified by the aWindow parameter.  If aWindow is nil, a pointer to
  67. *         the front-most Picture Document window is returned.
  68. \******************************************************************************/
  69.  
  70. WindowPtr NextPictDocWindow(
  71.     WindowPtr aWindow);
  72.  
  73.  
  74. /******************************************************************************\
  75. * NAME & SYNOPSIS:
  76. * IsPictDocWindow: Is a window a Picture Document window?
  77. *
  78. * PARAMETERS:
  79. * WindowPtr aWindow: Window to test for Picture Document-ness
  80. *
  81. * DEFINITION:
  82. * When it needs to be determined whether a window is a Picture Document window
  83. * or not, this routine is called.  It returns true if aWindow is a Picture
  84. * Document window, or false if not.  If aWindow is nil, then false is returned.
  85. *
  86. * RETURN VALUES:
  87. * Result: Boolean true if the aWindow parameter refers to a Picture Document
  88. *         window; false if not.
  89. \******************************************************************************/
  90.  
  91. Boolean IsPictDocWindow(
  92.     WindowPtr aWindow);
  93.  
  94.  
  95. /******************************************************************************\
  96. * NAME & SYNOPSIS:
  97. * DrawPictDoc: Draw the contents of a Picture Document
  98. *
  99. * PARAMETERS:
  100. * WindowPtr docWindow: Ptr to Picture Document window being drawn
  101. *
  102. * DEFINITION:
  103. * The contents of the Picture Document window specified by docWindow are
  104. * drawn into the window.  The contents include the image, the scroll bars, and
  105. * the grow icon.  This routine is called in response to update events.
  106. *
  107. * RETURN VALUES:
  108. * None
  109. \******************************************************************************/
  110.  
  111. void DrawPictDoc(
  112.     WindowPtr docWindow);
  113.  
  114.  
  115. /******************************************************************************\
  116. * NAME & SYNOPSIS:
  117. * ClickPictDoc: Handle a mouse click in a Picture Document window
  118. *
  119. * PARAMETERS:
  120. * WindowPtr   docWindow:   Pointer to Picture Document window that was clicked
  121. * EventRecord *clickEvent: Event that recorded the mouse click
  122. *
  123. * DEFINITION:
  124. * Whenever there’s a mouse-down event in a Picture Document window, this routine
  125. * is called to handle the mouse click.  There are two cases in which there can
  126. * be a mouse click in a Picture Document window and ClickPictDoc is not called:
  127. * if the title bar of a window is clicked, DoWindowDrag in ColorReset.c is
  128. * called to let the user move the window; if the grow icon is clicked,
  129. * GrowPictDoc, defined below, is called to let the user change the size of the
  130. * window.
  131. *
  132. * ClickPictDoc handles mouse clicks in the image within the Picture Document
  133. * window by letting the user draw paint into the image.  Clicks in either of the
  134. * two scroll bars are handled by scrolling the image in the way that the user
  135. * wants.
  136. *
  137. * RETURN VALUES:
  138. * None
  139. \******************************************************************************/
  140.  
  141. void ClickPictDoc(
  142.     WindowPtr   docWindow,
  143.     EventRecord *clickEvent);
  144.  
  145.  
  146. /******************************************************************************\
  147. * NAME & SYNOPSIS:
  148. * GrowPictDoc: Let the user change the size of a Picture Document window
  149. *
  150. * PARAMETERS:
  151. * WindowPtr   docWindow:   Picture Document window that’s to be grown
  152. * EventRecord *clickEvent: Mouse down event
  153. *
  154. * DEFINITION:
  155. * GrowPictDoc is called whenever there’s a click in the grow icon of a Picture
  156. * Document window.  It lets the user grow and shrink the window until he or she
  157. * lets go of the mouse button.  The Picture Document window is then updated for
  158. * the new size of the window.
  159. *
  160. * DESCRIPTION:
  161. * GrowWindow is called with a boundary rectangle that specifies that the window
  162. * has a minimum size of kMinWindowSize (defined at the top of this source file)
  163. * and a maximum size that’s the size of the image.  After the user releases the
  164. * mouse button, SizeWindow is called to change the size of the window, and
  165. * ResizePictDoc (defined below) is called to update the Picture Document to the
  166. * new size.
  167. *
  168. * RETURN VALUES:
  169. * None
  170. \******************************************************************************/
  171.  
  172. void GrowPictDoc(
  173.     WindowPtr   docWindow,
  174.     EventRecord *clickEvent);
  175.  
  176.  
  177. /******************************************************************************\
  178. * NAME & SYNOPSIS:
  179. * ActivatePictDoc: Activate or deactivate a Picture Document window
  180. *
  181. * PARAMETERS:
  182. * WindowPtr docWindow:      Picture Document window that’s being (de)activated
  183. * Boolean   becomingActive: True if window is becoming active; false otherwise
  184. *
  185. * DEFINITION:
  186. * ActivatePictDoc is called whenever a Picture Document window is activated or
  187. * deactivated.  This is just to handle the visual aspects of window activation,
  188. * such as hiding or showing the grow icon and the scroll bars.
  189. *
  190. * RETURN VALUES:
  191. * None
  192. \******************************************************************************/
  193.  
  194. void ActivatePictDoc(
  195.     WindowPtr docWindow,
  196.     Boolean   becomingActive);
  197.  
  198.  
  199. /******************************************************************************\
  200. * NAME & SYNOPSIS:
  201. * FixPictDocMenus: Enable or check menus for Picture Documents
  202. *
  203. * PARAMETERS:
  204. * WindowPtr docWindow: Picture Document to apply menu dimming to
  205. *
  206. * DEFINITION:
  207. * FixPictDocMenus is called whenever the state of the menus associated with a
  208. * Picture Document window is changed, like when a Picture Document is opened, or
  209. * if some state of the Picture Document has changed.  FixPictDocMenus only
  210. * enables or checks menu items; it doesn’t disable or uncheck items.  Disabling
  211. * and unchecking is handled in MenuHandler.c.
  212. *
  213. * RETURN VALUES:
  214. * None
  215. \******************************************************************************/
  216.  
  217. void FixPictDocMenus(
  218.     WindowPtr docWindow);
  219.  
  220.  
  221. /******************************************************************************\
  222. * NAME & SYNOPSIS:
  223. * DoOpenPictDoc: Open a new Picture Document
  224. *
  225. * PARAMETERS:
  226. * None
  227. *
  228. * DEFINITION:
  229. * When the user chooses Open… from the file menu to open an existing Picture
  230. * Document file (really a PICT file).  The user is asked which PICT file to
  231. * open, and then a new window appears with the picture displayed in it.  A
  232. * pointer to this window is returned.  If the Picture Document couldn’t be
  233. * opened for some reason, an alert is displayed which tells the user what went
  234. * wrong, and no Picture Document window is opened.
  235. *
  236. * If the Picture Document is already open from another application, then it
  237. * can’t be opened from this application, and an alert is given to the user.  If
  238. * the Picture Document is already open within this application, then that
  239. * document’s window is simply activated and its pointer is returned.
  240. *
  241. * RETURN VALUES:
  242. * Result: Pointer to the new Picture Document window.  If a Picture Document
  243. *         window couldn’t be created, nil is returned.
  244. \******************************************************************************/
  245.  
  246. WindowPtr DoOpenPictDoc(void);
  247.  
  248.  
  249. /******************************************************************************\
  250. * NAME & SYNOPSIS:
  251. * DoSaveAsPictDoc: Save a new Picture Document
  252. *
  253. * PARAMETERS:
  254. * WindowPtr docWindow: Pointer to Picture Document window being saved
  255. *
  256. * DEFINITION:
  257. * This routine is called when the user chooses Save As… from the File menu.  It
  258. * saves a new Picture Document as a PICT file.
  259. *
  260. * RETURN VALUES:
  261. * None
  262. \******************************************************************************/
  263.  
  264. void DoSaveAsPictDoc(
  265.     WindowPtr docWindow);
  266.  
  267.  
  268. /******************************************************************************\
  269. * NAME & SYNOPSIS:
  270. * DoClosePictDoc: Close a Picture Document window
  271. *
  272. * PARAMETERS:
  273. * WindowPtr docWindow: Pointer to Picture Document window being closed
  274. *
  275. * DEFINITION:
  276. * This routine closes the Picture Document window specified by the
  277. * docWindow parameter.  All memory associated with the window is disposed
  278. * of and the window is closed.  At this time, true is always returned.
  279. *
  280. * RETURN VALUES:
  281. * Result: Always true
  282. \******************************************************************************/
  283.  
  284. Boolean DoClosePictDoc(
  285.     WindowPtr docWindow);
  286.  
  287.  
  288. /******************************************************************************\
  289. * NAME & SYNOPSIS:
  290. * ChooseBrushColor: Choose a color for the brush
  291. *
  292. * PARAMETERS:
  293. * WindowPtr docWindow: Window whose brush color is to be chosen
  294. *
  295. * DEFINITION:
  296. * When the user chooses Brush Color… from the Color menu, this routine is called
  297. * to present the Color Picker to the user so that he or she can choose a new
  298. * color for the brush.
  299. *
  300. * RETURN VALUES:
  301. * None
  302. \******************************************************************************/
  303.  
  304. void ChooseBrushColor(
  305.     WindowPtr docWindow);
  306.     
  307. pascal void ScrollActionProc(
  308.     ControlHandle control, /* Handle to clicked control */
  309.     short         part);   /* Part number of clicked control part */
  310.  
  311. pascal void InfoBits(
  312.     BitMapPtr srcBits,
  313.     Rect      *srcRect,
  314.     Rect      *dstRect,
  315.     short     mode,
  316.     RgnHandle maskRgn);
  317.     
  318. pascal void FileGetPic(
  319.     Ptr   dataPtr,
  320.     short byteCount);
  321.  
  322. pascal void FilePutPic(
  323.     Ptr   dataPtr,
  324.     short byteCount);
  325.  
  326.  
  327.  
  328. #endif
  329.